/*
 * @lc app=leetcode.cn id=513 lang=javascript
 *
 * [513] 找树左下角的值
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {TreeNode} root
 * @return {number}
 */
var findBottomLeftValue = function(root) {
    if(root===null){
        return 
    }
    const queque=[root]
    while(queque.length){
        const curLevel=[]
        const len=queque.length
        for(let i=0;i<len;i++){
             const node=queque.shift()
             curLevel.push(node.val)
             node.left&&queque.push(node.left)
             node.right&&queque.push(node.right)
        }
        if(queque.length===0){
            return curLevel[0]
        }
    }
};
// @lc code=end

